/*
 * main.cpp
 *
 *  Created on: 03.02.2013
 *      Author: Maksim Lazeba
 */

#include "region_search.h"
#include <iostream>

int main()
{
	int d;
	std::cin >> d;

	size_t n;
	std::cin >> n;

	int m;
	std::cin >> m;

	std::vector<double> x(d);

	std::vector<point_t> points;

	for (size_t i = 0; i < n; i++)
	{
		for (int j = 0; j < d; j++)
			std::cin >> x[j];
		points.push_back(point_t(x, i + 1, d));
	}

	region_tree tree(points,d);

	for (int i = 0; i < m; i++)
	{
		for (int j = 0; j < d; j++)
			std::cin >> x[j];
		point_t a(x, 0, d);
		for (int j = 0; j < d; j++)
			std::cin >> x[j];
		point_t b(x, 0, d);

		std::vector<point_t> ans = tree.get_points_in_rect(rect_t(a, b));

		std::cout << ans.size() << "\n";
		std::cout.precision(30);
		for (auto i = ans.begin(); i < ans.end(); i++)
		{
			std::cout << i->id << " ";
		}
		std::cout << "\n";
	}
}

